package com.heima.controller;

import com.heima.mapper.RoleMapper;
import com.heima.pojo.domain.Role;
import com.heima.pojo.dto.VmDto;
import com.heima.pojo.domain.PageResult;
import com.heima.pojo.dto.VmPostDto;
import com.heima.pojo.vo.VmNodeVo;
import com.heima.service.VmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class VmController {

    @Autowired
    private VmService vmService;
    @Autowired
    private RoleMapper roleMapper;


    @GetMapping("/api/vm-service/vm/search")
    public PageResult<VmNodeVo> search(VmDto vmDto){
        return vmService.search(vmDto);
    }

    @PostMapping("/api/vm-service/vm")
    public Boolean post(@RequestBody VmPostDto vmPostDto){
        return vmService.add(vmPostDto);
    }

    @GetMapping("/api/user-service/role")
    public List<Role> searRole(){
        return roleMapper.selectList(null);
    }

}
